package com.huan.network;

import com.huan.bean.PageViewCount;
import org.apache.flink.streaming.api.functions.windowing.WindowFunction;
import org.apache.flink.streaming.api.windowing.windows.TimeWindow;
import org.apache.flink.util.Collector;


//实现自定义窗口函数
public class PageCountResult implements WindowFunction<Long, PageViewCount, String, TimeWindow> {
    @Override
    public void apply(String url, TimeWindow window, Iterable<Long> input, Collector<PageViewCount> out) throws Exception {
        //按 PageViewCount 类格式输出
        out.collect(new PageViewCount(url, window.getEnd(), input.iterator().next()));
    }
}
